﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditCustQuoteQuery.aspx.cs" Inherits="Skyworth.CRM.Web.CustomerManagement.EditCustQuoteQuery" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>销售管理平台 | 客户报价管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <%--[if IE]>
     <link href="../themes/css/ieHack.css" rel="stylesheet" type="text/css" />
    <![endif]--%>
    <script src="../javascripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <link href="../themes/silver/style.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/core.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/pages.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/wbox.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/Messagebox.css" rel="stylesheet" type="text/css" />
    <link href="../javascripts/My97DatePicker/skin/WdatePicker.css" rel="stylesheet" type="text/css" />
    <script src="../javascripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="../javascripts/jquery.autocomplete.js" type="text/javascript"></script>
     <style type="text/css">        
        a
        {
            display: block;
        }
        .red
        {
            color: Red;
            font-weight: bold;
        }       
        table
        {
            border-collapse: collapse;
            border-spacing: 0;
            table-layout: fixed;
            width: 100%;
            border: solid 1px #e7e7e7;
        }
        table tr td
        {
            border-bottom: solid 1px #e7e7e7;
            padding: 0px 3px;
            background-color: #EFEFEF;
        }
        td label
        {
            padding: 2px 2px;
        }
        td.left
        {
            border-right: solid 1px #e7e7e7;
            width: 65px;
        }
        td.right
        {
            background: #FFF;
        }
        td.right, td.readOnly
        {
            padding: 5px 3px;
        }
        .content
        {
            overflow: auto;           
            border: solid 1px #CCC;
            line-height: 21px;
            background: #FFF;
            padding: 5px;
        }
        input[type=text]
        {
 	        width:180px;
        }
        select
        {
        	width:185px;
        	height:25px;
        }
        
    </style>
     <script type="text/javascript">
         function SaveCheck() {
             var txtBussId = $("#txtBussId").val();
             var hidProductId = $("#hidProductId").val();
             var txtQty = $("#txtQty").val();
             var txtDate = $("#txtDate").val();
             if (txtBussId == "" || txtBussId.length <= 0) {
                 alert("请输入商机单号！");
                 $("#txtBussId").focus();
                 return false;
             }
             if (hidProductId == "" || hidProductId.length <= 0) {
                 alert("请输入产品名称！");
                 $("#hidProductId").focus();
                 return false;
             }
             var number = parseFloat(txtQty);
             if (isNaN(number) || number <= 0) {
                 alert("订购数量不正确，必须是大于0的数字.");
                 $("#txtQty").focus();
                 result = false;
             }
             if (txtDate == "" || txtDate.length <= 0) {
                 alert("请输入制单日期！");
                 $("#txtDate").focus();
                 return false;
             }
         }

         $(document).ready(function () {
             $("input[type=text],textarea").addClass("textInput").focus(function () { $(this).addClass("focus"); }).blur(function () { $(this).removeClass("focus") });
             $("#btnClose").click(function () {
                 parent.addWindow.close();
             })
             $("#btnSave").click(function () {
                 return SaveCheck();
             })

             $("#txtBussCode").autocomplete("../Service/BussinessoppHandler.ashx", {
                 minChars: 1, autoFill: false, scroll: false, mustMatch: true, selectFirst: true,
                 formatItem: function (result, i, max) {
                     var item = "<span>" + result[1] + "</span>"
                     return item;
                 },
                 //extraParams: { CustId: 0 },
                 formatResult: function (row) { return row[1]; }
             });
             $("#txtBussCode").result(function (event, data, formatted) {
                 if (data && data.length > 0) {
                     $("#txtBussId").val(data[0]);
                 }
             });

             $("#txtProductName").autocomplete("../Service/OrderProduct.ashx", {
                 minChars: 1, autoFill: false, scroll: false, mustMatch: true, selectFirst: true,
                 formatItem: function (result, i, max) {
                     var item = "<span>" + result[1] + "</span>"
                     return item;
                 },
                 extraParams: { CustId: 0 },
                 formatResult: function (row) { return row[1]; }
             });
             $("#txtProductName").result(function (event, data, formatted) {
                 if (data && data.length > 0) {
                     $("#hidProductId").val(data[0]);
                     $("#txtProductName").val(data[1]);
                     $("#txtVolume").val(data[3]);
                     $("#txtPrice").val(data[4]);
                     $("#txtTax").val(data[5]);
                     $("#txtTaxPrice").val(data[6]);
                     $("#txtUnit").val(data[2]);
                 }
             });

             $("#txtQty").blur(function () {
                 var count = $(this).val();
                 if (new RegExp(/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/).test(count)) {
                     count = parseFloat(count);
                     if (!isNaN(count) && count > 0) {
                         var perVolume = $("#txtVolume").val();
                         var perPrice = $("#txtPrice").val();
                         var perTaxPrice = $("#txtTax").val();
                         var volume = count * perVolume;
                         var price = count * perPrice;
                         var taxPrice = count * perTaxPrice;
                         $("#txtQtyVolume").val(volume);
                         $("#txtAmount").val(volume);
                         $("#txtFaxAmount").val(volume);
                     }
                     else {
                         $(this).val(0);
                         $("#txtQtyVolume").val(0);
                         $("#txtAmount").val(0);
                         $("#txtFaxAmount").val(0);
                     }
                 }
                 else {
                     $(this).val(0);
                     $("#txtQtyVolume").val(0);
                     $("#txtAmount").val(0);
                     $("#txtFaxAmount").val(0);
                 }
             })

             $("div.button").hover(function () { $(this).addClass("buttonHover"); },
               function () { $(this).removeClass("buttonHover"); });
         })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <div style="margin:2px;">
            <div class="panel" >
                <div class="panelHeader">
                    <div class="panelHeaderContent">
                        <h1>
                            客户报价信息</h1>
                    </div>
                </div>
                <div class="panelContent">
                    <div class="content" >
                        <table>
                            <tr>
                                <td class="left">
                                    <label>报价单号：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtQuoteCode" CssClass="textInput" Text="自动生成" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                                <td class="left">
                                    <label>商机单号：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtBussCode" CssClass="required textInput" runat="server" MaxLength="200"></asp:TextBox>
                                    <input type="hidden" style="display: none;" id="txtBussId" value="0" runat="server" />
                                </td>
                            </tr>
                            <tr>                
                                <td class="left">
                                    <label>产品名称：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtProductName" CssClass="required textInput" runat="server" MaxLength="200"></asp:TextBox>
                                    <input type="hidden" style="display: none;" id="hidProductId" runat="server" />
                                </td>
                                 <td class="left">
                                    <label>单位体积：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtVolume" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>                
                                <td class="left">
                                    <label>不含税单价：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtPrice" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                                 <td class="left">
                                    <label>税率：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtTax" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>                
                                <td class="left">
                                    <label>含税单价：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtTaxPrice" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                                 <td class="left">
                                    <label>订购数量：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtQty" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>                
                                <td class="left">
                                    <label>计量单位：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtUnit" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                                 <td class="left">
                                    <label>总体积：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtQtyVolume" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>                
                                <td class="left">
                                    <label>不含税金额：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtAmount" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                                 <td class="left">
                                    <label>含税金额：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtFaxAmount" CssClass="txt" runat="server" MaxLength="100"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>                
                                <td class="left">
                                    <label>备注：</label>
                                </td>
                                <td class="right" colspan="3">
                                    <asp:TextBox ID="txtNote" CssClass="txt" Width="450px" Height="40px" TextMode="MultiLine" runat="server" MaxLength="250"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <%--<td class="left">
                                    <label>制单人：</label>
                                </td>
                                <td class="right">
                                    <asp:TextBox ID="txtMaker" CssClass="required textInput" runat="server" MaxLength="200"></asp:TextBox>
                                    <input type="hidden" style="display: none;" id="txtEmpId" runat="server" />
                                </td>--%>
                                <td class="left">
                                    <label>制单日期：</label>
                                </td>
                                <td class="right" colspan="3">
                                    <asp:TextBox ID="txtDate" runat="server" Width="100" CssClass="required textInput"
                                    onClick="WdatePicker({skin:'ext'})"></asp:TextBox>
                                </td>
                            </tr>                            
                            <tr>
                                <td colspan="4" class="readOnly" style="padding-right: 12px; background: url('../themes/default/images/grid/grid.png') repeat scroll 0 0">
                                                   <a title="清空" href="javascript:void(0)" class="button" style="float:left" id="btnClose"><span>关闭</span></a>
                                   
                                                    <div class="button" style="float: right;margin-right: 5px;">
                                                        <div class="buttonContent">
                                                            <asp:Button ID="btnSave" runat="server" Text="保存" 
                                                                CssClass="serverButton" onclick="btnSave_Click" />
                                                        </div>
                                                    </div>
                                                    <div style="clear:both;float:none;display:none;"></div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="panelFooter">
                    <div class="panelFooterContent">                        
                    </div>
               </div> 
           </div>
        </div>
    </div>
    </form>
</body>
</html>